package com.vrv.netmgr.entry;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.ExpandableListView.OnGroupClickListener;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.vrv.common.adapter.VRVExpandableListAdapter;
import com.vrv.common.util.DataSetUtil;
import com.vrv.common.util.StringUtils;
import com.vrv.netmgr.R;
import com.vrv.netmgr.alarm.chart.AlarmChartActivity;
import com.vrv.netmgr.persistent.LoginSharedPreferencesHelper;
import com.vrv.netmgr.vo.LoginInfo;

/**
 * @Description 审计报警导航主界面
 *
 * @author gaopei
 * @date
 */
public class AlarmActivity extends Activity {
    private boolean isBack;

    private Boolean isNavgate = Boolean.TRUE;

    private Boolean isTop = true;

    private LinearLayout leverTwoLayout;

    private ExpandableListAdapter mAdapter;

    private ExpandableListView expandListView;

    private List<Map<String, String>> groups = new ArrayList<Map<String, String>>();

    private List<List<Map<String, String>>> childs = new ArrayList<List<Map<String, String>>>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initViewSetting();
    }

    /**
     * 加载初始化布局，初始化组件
     */
    public void initViewSetting() {

        isTop = Boolean.TRUE;

        setContentView(R.layout.alarm_nine_cell);
        leverTwoLayout = (LinearLayout) this.findViewById(R.id.lever_2_layout);
        leverTwoLayout.setVisibility(View.VISIBLE);

        MainTab mainTab = (MainTab) getParent();
        mainTab.setTitle(getResources().getString(R.string.alarm), false);
        RelativeLayout navLayout = (RelativeLayout) this.findViewById(R.id.alarmChart);

        RelativeLayout nav1Layout = (RelativeLayout) this.findViewById(R.id.navAlarmDataQuery);
        nav1Layout.setTag(Boolean.TRUE);
        TextView bubble0 = (TextView) findViewById(R.id.commentWidget_0);
        bubble0.setVisibility(View.GONE);

        RelativeLayout nav2Layout = (RelativeLayout) this.findViewById(R.id.navAuditQuery);
        nav2Layout.setTag(Boolean.TRUE);
        TextView bubble1 = (TextView) findViewById(R.id.commentWidget_1);
        bubble1.setVisibility(View.GONE);

        RelativeLayout nav3Layout = (RelativeLayout) this.findViewById(R.id.navOprAndMaintMonitor);
        nav3Layout.setBackgroundColor(getResources().getColor(R.color.gray1));
        nav3Layout.setTag(Boolean.FALSE);
        TextView bubble2 = (TextView) findViewById(R.id.commentWidget_2);
        bubble2.setVisibility(View.GONE);

        RelativeLayout nav4Layout = (RelativeLayout) this.findViewById(R.id.navCascadeAlarmEvent);
        nav4Layout.setTag(Boolean.FALSE);
        nav4Layout.setBackgroundColor(getResources().getColor(R.color.gray1));
        TextView bubble3 = (TextView) findViewById(R.id.commentWidget_3);
        bubble3.setVisibility(View.VISIBLE);
        nav4Layout.setVisibility(View.VISIBLE);

        RelativeLayout nav5Layout = (RelativeLayout) this.findViewById(R.id.navUSBLabelQuery);
        nav5Layout.setTag(Boolean.FALSE);
        TextView bubble4 = (TextView) findViewById(R.id.commentWidget_4);
        bubble4.setVisibility(View.VISIBLE);
        nav5Layout.setVisibility(View.INVISIBLE);

        RelativeLayout nav6Layout = (RelativeLayout) this.findViewById(R.id.navDistriDataQuery);
        nav6Layout.setTag(Boolean.FALSE);
        TextView bubble5 = (TextView) findViewById(R.id.commentWidget_5);
        bubble5.setVisibility(View.VISIBLE);
        nav6Layout.setVisibility(View.INVISIBLE);

        navLayout.setOnClickListener(new ClickLLListener());
        nav1Layout.setOnClickListener(new ClickLLListener());
        nav2Layout.setOnClickListener(new ClickLLListener());
        nav3Layout.setOnClickListener(new ClickLLListener());
        nav4Layout.setOnClickListener(new ClickLLListener());
        nav5Layout.setOnClickListener(new ClickLLListener());
        nav6Layout.setOnClickListener(new ClickLLListener());

    }

    /**
     * 切换到第三级布局
     */
    public void changeToLever3ViewSetting() {
        isTop = Boolean.FALSE;

        setContentView(R.layout.lever_config_nine_cell);// 切换布局
        expandListView = (ExpandableListView) findViewById(R.id.expand_list_view);
        mAdapter = new VRVExpandableListAdapter(AlarmActivity.this, groups, R.layout.groups, childs, R.layout.childs);
        expandListView.setAdapter(mAdapter);
        expandListView.setOnGroupClickListener(new OnGroupClickListener() {
            @Override
            public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
                if (mAdapter.getChildrenCount(groupPosition) > 0) {
                    Log.d("#caobl#", "" + groupPosition);
                    return false;
                } else {

                    Map<String, String> groupItem = groups.get(groupPosition);
                    String activityName = groupItem.get("activityName");

                    if (StringUtils.isBlank(activityName))
                        return true;

                    ComponentName componentName = new ComponentName(AlarmActivity.this, activityName);
                    Intent intent = new Intent();
                    intent.setComponent(componentName);
                    intent.putExtra("title", groupItem.get("child"));
                    isNavgate = Boolean.FALSE;
                    overridePendingTransition(R.anim.push_right_out, R.anim.push_right_in);
                    startActivity(intent);

                    return false;
                }
            }
        });

        expandListView.setOnChildClickListener(new OnChildClickListener() {
            @Override
            public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {

                Map<String, String> childItem = childs.get(groupPosition).get(childPosition);
                String activityName = childItem.get("activityName");

                if (StringUtils.isBlank(activityName))
                    return true;

                ComponentName componentName = new ComponentName(AlarmActivity.this, activityName);
                Intent intent = new Intent();
                intent.setComponent(componentName);
                intent.putExtra("title", childItem.get("group"));
                isNavgate = Boolean.FALSE;
                overridePendingTransition(R.anim.push_right_out, R.anim.push_right_in);
                startActivity(intent);

                return false;
            }
        });
    }

    private class ClickLLListener implements View.OnClickListener {

        @Override
        public void onClick(View v) {
            // 1.初始化数据
            switch (v.getId()) {
            case R.id.alarmChart:
                startActivity(new Intent(AlarmActivity.this, AlarmChartActivity.class));
                return;
            case R.id.navAlarmDataQuery:
                if (!Boolean.valueOf(String.valueOf(v.getTag())))
                    return;
                fillLever3DataSet(0, getResources().getString(R.string.strAlarmDataQuery));
                break;
            case R.id.navAuditQuery:
                if (!Boolean.valueOf(String.valueOf(v.getTag())))
                    return;
                fillLever3DataSet(1, getResources().getString(R.string.strAuditQuery));
                break;
            case R.id.navOprAndMaintMonitor:
                if (!Boolean.valueOf(String.valueOf(v.getTag())))
                    return;
                fillLever3DataSet(2, getResources().getString(R.string.strOprAndMaintMonitor));
                break;
            case R.id.navCascadeAlarmEvent:
                if (!Boolean.valueOf(String.valueOf(v.getTag())))
                    return;
                fillLever3DataSet(3, getResources().getString(R.string.strCascadeAlarmEvent));
                break;
            case R.id.navUSBLabelQuery:
                if (!Boolean.valueOf(String.valueOf(v.getTag())))
                    return;
                fillLever3DataSet(4, getResources().getString(R.string.strUSBLabelQuery));
                break;
            case R.id.navDistriDataQuery:
                if (!Boolean.valueOf(String.valueOf(v.getTag())))
                    return;
                fillLever3DataSet(5, getResources().getString(R.string.strDistriDataQuery));
                break;

            default:
                break;
            }

            // 2.切换布局填充adapter
            changeToLever3ViewSetting();
        }
    }

    /**
     * 初始化静态数据
     *
     * @param string
     *
     * @param i
     */
    private void fillLever3DataSet(int index, String title) {

        MainTab mainTab = (MainTab) getParent();
        mainTab.setTitle(title, true);
        mainTab.getBackBtn().setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });

        groups.clear();

        if (0 == index) {
            // [start] 本地报警数据查询
            Map<String, String> groupMap0 = new HashMap<String, String>();
            groupMap0.put("key", "0");
            groupMap0.put("group", "本地区域报警数据统计");
            groupMap0.put("activityName", "com.vrv.netmgr.alarm.chart.AlarmStatisticsActivity");
            groups.add(groupMap0);

            Map<String, String> groupMap1 = new HashMap<String, String>();
            groupMap1.put("key", "0");
            groupMap1.put("group", "本地报警数据汇总");
            groupMap1.put("activityName", "");
            groups.add(groupMap1);

            Map<String, String> groupMap2 = new HashMap<String, String>();
            groupMap2.put("key", "0");
            groupMap2.put("group", "阻断报警");
            groupMap2.put("activityName", "");
            groups.add(groupMap2);

            Map<String, String> groupMap3 = new HashMap<String, String>();
            groupMap3.put("key", "0");
            groupMap3.put("group", "设备变化");
            groupMap3.put("activityName", "com.vrv.netmgr.alarm.EquipmentChangedQryActivity");
            groups.add(groupMap3);

            Map<String, String> groupMap4 = new HashMap<String, String>();
            groupMap4.put("key", "0");
            groupMap4.put("group", "IP绑定变化");
            groupMap4.put("activityName", "");
            groups.add(groupMap4);

            Map<String, String> groupMap5 = new HashMap<String, String>();
            groupMap5.put("key", "0");
            groupMap5.put("group", "模拟报警");
            groupMap5.put("activityName", "com.vrv.netmgr.alarm.EquipmentChangedListActivity");
            groups.add(groupMap5);

            Map<String, String> groupMap6 = new HashMap<String, String>();
            groupMap6.put("key", "0");
            groupMap6.put("group", "其他报警");
            groupMap6.put("activityName", "");
            groups.add(groupMap6);

            Map<String, String> groupMap7 = new HashMap<String, String>();
            groupMap7.put("key", "0");
            groupMap7.put("group", "探头卸载");
            groupMap7.put("activityName", "");
            groups.add(groupMap7);

            Map<String, String> groupMap8 = new HashMap<String, String>();
            groupMap8.put("key", "0");
            groupMap8.put("group", "病毒行为");
            groupMap8.put("activityName", "");
            groups.add(groupMap8);

            Map<String, String> groupMap9 = new HashMap<String, String>();
            groupMap9.put("key", "0");
            groupMap9.put("group", "流量异常");
            // groupMap9.put("activityName",
            // "com.vrv.netmgr.alarm.NetFlowAbnormalActivity");
            groupMap9.put("activityName", "");
            groups.add(groupMap9);

            Map<String, String> groupMap10 = new HashMap<String, String>();
            groupMap10.put("key", "0");
            groupMap10.put("group", "多操作系统");
            groupMap10.put("activityName", "");
            groups.add(groupMap10);

            Map<String, String> groupMap11 = new HashMap<String, String>();
            groupMap11.put("key", "0");
            groupMap11.put("group", "违规外联");
            groupMap11.put("activityName", "");
            groups.add(groupMap11);

            Map<String, String> groupMap12 = new HashMap<String, String>();
            groupMap12.put("key", "0");
            groupMap12.put("group", "违规上网统计");
            groupMap12.put("activityName", "com.vrv.netmgr.alarm.IllegalNetStatActivity");
            groups.add(groupMap12);

            Map<String, String> groupMap13 = new HashMap<String, String>();
            groupMap13.put("key", "0");
            groupMap13.put("group", "VIFR报警");
            groupMap13.put("activityName", "");
            groups.add(groupMap13);

            Map<String, String> groupMap14 = new HashMap<String, String>();
            groupMap14.put("key", "0");
            groupMap14.put("group", "超出网段限制");
            groupMap14.put("activityName", "");
            groups.add(groupMap14);

            Map<String, String> groupMap15 = new HashMap<String, String>();
            groupMap15.put("key", "0");
            groupMap15.put("group", "设备审计");
            // groupMap15.put("activityName",
            // "com.vrv.netmgr.alarm.RelateAuditQryActivity");
            /** update by zxb 20130726 暂时关闭 */
            groupMap15.put("activityName", "");
            groups.add(groupMap15);
            // [end] 本地报警数据查询
        } else if (1 == index) {
            Map<String, String> groupMap15 = new HashMap<String, String>();
            groupMap15.put("key", "1");
            groupMap15.put("group", "硬件控制审计");
            groupMap15.put("activityName", "");
            groups.add(groupMap15);

            Map<String, String> groupMap16 = new HashMap<String, String>();
            groupMap16.put("key", "1");
            groupMap16.put("group", "上网访问审计");
            groupMap16.put("activityName", "com.vrv.netmgr.alarm.NetVisitAuditActivity");
            groups.add(groupMap16);

            Map<String, String> groupMap17 = new HashMap<String, String>();
            groupMap17.put("key", "1");
            groupMap17.put("group", "上网访问统计");
            groupMap17.put("activityName", "");
            groups.add(groupMap17);

            Map<String, String> groupMap18 = new HashMap<String, String>();
            groupMap18.put("key", "1");
            groupMap18.put("group", "IM即时通讯审计");
            groupMap18.put("activityName", "");
            groups.add(groupMap18);

            Map<String, String> groupMap19 = new HashMap<String, String>();
            groupMap19.put("key", "1");
            groupMap19.put("group", "文件输出审计");
            groupMap19.put("activityName", "");
            groups.add(groupMap19);

            Map<String, String> groupMap20 = new HashMap<String, String>();
            groupMap20.put("key", "1");
            groupMap20.put("group", "文档打印记录");
            groupMap20.put("activityName", "");
            groups.add(groupMap20);

            Map<String, String> groupMap21 = new HashMap<String, String>();
            groupMap21.put("key", "1");
            groupMap21.put("group", "文件保护审计");
            groupMap21.put("activityName", "");
            groups.add(groupMap21);

            Map<String, String> groupMap22 = new HashMap<String, String>();
            groupMap22.put("key", "1");
            groupMap22.put("group", "违规软件及进程");
            groupMap22.put("activityName", "com.vrv.netmgr.alarm.IllegalSoftProcessQryActivity");
            groups.add(groupMap22);

            Map<String, String> groupMap23 = new HashMap<String, String>();
            groupMap23.put("key", "1");
            groupMap23.put("group", "上外网痕迹检查");
            groupMap23.put("activityName", "");
            groups.add(groupMap23);

            Map<String, String> groupMap24 = new HashMap<String, String>();
            groupMap24.put("key", "1");
            groupMap24.put("group", "代理上网审计");
            groupMap24.put("activityName", "");
            groups.add(groupMap24);

            Map<String, String> groupMap25 = new HashMap<String, String>();
            groupMap25.put("key", "1");
            groupMap25.put("group", "安全刻录审计");
            groupMap25.put("activityName", "");
            groups.add(groupMap25);

            Map<String, String> groupMap26 = new HashMap<String, String>();
            groupMap26.put("key", "1");
            groupMap26.put("group", "自动关机审计");
            groupMap26.put("activityName", "");
            groups.add(groupMap26);

            Map<String, String> groupMap27 = new HashMap<String, String>();
            groupMap27.put("key", "1");
            groupMap27.put("group", "远程协助审计");
            groupMap27.put("activityName", "");
            groups.add(groupMap27);

            Map<String, String> groupMap28 = new HashMap<String, String>();
            groupMap28.put("key", "1");
            groupMap28.put("group", "远程协助文件传输审计");
            groupMap28.put("activityName", "");
            groups.add(groupMap28);

            Map<String, String> groupMap29 = new HashMap<String, String>();
            groupMap29.put("key", "1");
            groupMap29.put("group", "IP异常接入审计");
            groupMap29.put("activityName", "");
            groups.add(groupMap29);

            Map<String, String> groupMap30 = new HashMap<String, String>();
            groupMap30.put("key", "1");
            groupMap30.put("group", "VRV进程审计");
            groupMap30.put("activityName", "");
            groups.add(groupMap30);

            Map<String, String> groupMap31 = new HashMap<String, String>();
            groupMap31.put("key", "1");
            groupMap31.put("group", "其他行为审计");
            groupMap31.put("activityName", "");
            groups.add(groupMap31);

            Map<String, String> groupMap32 = new HashMap<String, String>();
            groupMap32.put("key", "1");
            groupMap32.put("group", "终端截图信息");
            groupMap32.put("activityName", "");
            groups.add(groupMap32);

            Map<String, String> groupMap33 = new HashMap<String, String>();
            groupMap33.put("key", "1");
            groupMap33.put("group", "终端录像信息");
            groupMap33.put("activityName", "");
            groups.add(groupMap33);

            Map<String, String> groupMap34 = new HashMap<String, String>();
            groupMap34.put("key", "1");
            groupMap34.put("group", "区域管理器工作日志");
            groupMap34.put("activityName", "");
            groups.add(groupMap34);

            Map<String, String> groupMap35 = new HashMap<String, String>();
            groupMap35.put("key", "1");
            groupMap35.put("group", "移动设备审计");
            groupMap35.put("activityName", "com.vrv.netmgr.alarm.MobileDevAuditActivity");
            groups.add(groupMap35);

            Map<String, String> groupMap36 = new HashMap<String, String>();
            groupMap36.put("key", "1");
            groupMap36.put("group", "key登录信息审计");
            groupMap36.put("activityName", "");
            groups.add(groupMap36);

            Map<String, String> groupMap37 = new HashMap<String, String>();
            groupMap37.put("key", "1");
            groupMap37.put("group", "文件操作次数统计");
            groupMap37.put("activityName", "");
            groups.add(groupMap37);

            Map<String, String> groupMap38 = new HashMap<String, String>();
            groupMap38.put("key", "1");
            groupMap38.put("group", "涉密信息查询");
            groupMap38.put("activityName", "");
            groups.add(groupMap38);

            Map<String, String> groupMap39 = new HashMap<String, String>();
            groupMap39.put("key", "1");
            groupMap39.put("group", "策略执行力度查询");
            groupMap39.put("activityName", "");
            groups.add(groupMap39);

            Map<String, String> groupMap40 = new HashMap<String, String>();
            groupMap40.put("key", "1");
            groupMap40.put("group", "客户端白名单查询");
            groupMap40.put("activityName", "");
            groups.add(groupMap40);

            Map<String, String> groupMap41 = new HashMap<String, String>();
            groupMap41.put("key", "1");
            groupMap41.put("group", "设备变化审计");
            groupMap41.put("activityName", "");
            groups.add(groupMap41);

            Map<String, String> groupMap42 = new HashMap<String, String>();
            groupMap42.put("key", "1");
            groupMap42.put("group", "网络发现审计");
            groupMap42.put("activityName", "");
            groups.add(groupMap42);
        } else if (2 == index) {
            Map<String, String> groupMap43 = new HashMap<String, String>();
            groupMap43.put("key", "2");
            groupMap43.put("group", "区域流量排名");
            groupMap43.put("activityName", "");
            groups.add(groupMap43);

            Map<String, String> groupMap44 = new HashMap<String, String>();
            groupMap44.put("key", "2");
            groupMap44.put("group", "客户端流量排名");
            groupMap44.put("activityName", "");
            groups.add(groupMap44);

            Map<String, String> groupMap45 = new HashMap<String, String>();
            groupMap45.put("key", "2");
            groupMap45.put("group", "客户端流量统计");
            groupMap45.put("activityName", "");
            groups.add(groupMap45);

            Map<String, String> groupMap46 = new HashMap<String, String>();
            groupMap46.put("key", "2");
            groupMap46.put("group", "运维异常监控查询");
            groupMap46.put("activityName", "");
            groups.add(groupMap46);

            Map<String, String> groupMap47 = new HashMap<String, String>();
            groupMap47.put("key", "2");
            groupMap47.put("group", "运维异常监控统计");
            groupMap47.put("activityName", "");
            groups.add(groupMap47);

            Map<String, String> groupMap48 = new HashMap<String, String>();
            groupMap48.put("key", "2");
            groupMap48.put("group", "交换机端口管理");
            groupMap48.put("activityName", "");
            groups.add(groupMap48);

            Map<String, String> groupMap49 = new HashMap<String, String>();
            groupMap49.put("key", "2");
            groupMap49.put("group", "网管帮助设置");
            groupMap49.put("activityName", "");
            groups.add(groupMap49);

            Map<String, String> groupMap50 = new HashMap<String, String>();
            groupMap50.put("key", "2");
            groupMap50.put("group", "流量综合排名");
            groupMap50.put("activityName", "");
            groups.add(groupMap50);
        } else if (3 == index) {
            Map<String, String> groupMap51 = new HashMap<String, String>();
            groupMap51.put("key", "3");
            groupMap51.put("group", "违规外联事件");
            groupMap51.put("activityName", "");
            groups.add(groupMap51);

            Map<String, String> groupMap52 = new HashMap<String, String>();
            groupMap52.put("key", "3");
            groupMap52.put("group", "其他报警事件");
            groupMap52.put("activityName", "");
            groups.add(groupMap52);

            Map<String, String> groupMap53 = new HashMap<String, String>();
            groupMap53.put("key", "3");
            groupMap53.put("group", "违规上网统计");
            groupMap53.put("activityName", "");
            groups.add(groupMap53);

            Map<String, String> groupMap54 = new HashMap<String, String>();
            groupMap54.put("key", "3");
            groupMap54.put("group", "级联上报数据");
            groupMap54.put("activityName", "");
            groups.add(groupMap54);
        } else if (4 == index) {
            Map<String, String> groupMap55 = new HashMap<String, String>();
            groupMap55.put("key", "4");
            groupMap55.put("group", "USB标签制作查询");
            groupMap55.put("activityName", "");
            groups.add(groupMap55);

            Map<String, String> groupMap56 = new HashMap<String, String>();
            groupMap56.put("key", "4");
            groupMap56.put("group", "USB标签黑名单");
            groupMap56.put("activityName", "");
            groups.add(groupMap56);

            Map<String, String> groupMap57 = new HashMap<String, String>();
            groupMap57.put("key", "4");
            groupMap57.put("group", "USB授权个数查询");
            groupMap57.put("activityName", "");
            groups.add(groupMap57);
        } else if (5 == index) {
            Map<String, String> groupMap58 = new HashMap<String, String>();
            groupMap58.put("key", "5");
            groupMap58.put("group", "消息确认查询");
            groupMap58.put("activityName", "");
            groups.add(groupMap58);

            Map<String, String> groupMap59 = new HashMap<String, String>();
            groupMap59.put("key", "5");
            groupMap59.put("group", "普通文件分发查询");
            groupMap59.put("activityName", "");
            groups.add(groupMap59);

            Map<String, String> groupMap60 = new HashMap<String, String>();
            groupMap60.put("key", "5");
            groupMap60.put("group", "普通文件分发统计");
            groupMap60.put("activityName", "");
            groups.add(groupMap60);
        }

        childs.clear();
        for (int i = 0; i < groups.size(); i++) {
            List<Map<String, String>> varList = new ArrayList<Map<String, String>>(0);
            /** update by zxb 20130726 暂时关闭 */
            // if ((index == 0) && (i == 11)) {
            // Map<String, String> childMap0 = new HashMap<String, String>();
            // childMap0.put("child", "同时连接内外网");
            // childMap0.put("key", index + "");
            // childMap0.put("activityName",
            // "com.vrv.netmgr.alarm.OpenIONetActivity");
            // varList.add(childMap0);
            //
            // Map<String, String> childMap1 = new HashMap<String, String>();
            // childMap1.put("child", "断开内网上外网");
            // childMap1.put("key", index + "");
            // childMap1.put("activityName",
            // "com.vrv.netmgr.alarm.CloseIOpenONetActivity");
            // varList.add(childMap1);
            // }
            childs.add(varList);
        }
        DataSetUtil.checkDataSource(this.groups, this.childs);
    }

    /**
     *
     */
    Handler backHandler = new Handler() {
        public void handleMessage(Message msg) {
            isBack = false;
        }
    };

    @Override
    public void onBackPressed() {
        LoginInfo loginInfo = LoginSharedPreferencesHelper.getLoginInfo(getApplicationContext());
        if (!isTop) {
            initViewSetting();
        } else if (!isBack) {
            isBack = true;
            if (loginInfo.isAutoLogin()) {
                Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(getApplicationContext(), "再按一次到登录界面", Toast.LENGTH_SHORT).show();
            }
            backHandler.sendEmptyMessageDelayed(0, 2000);
        } else {
            if (loginInfo.isAutoLogin()) {
                finish();
                System.exit(0);
            } else {
                finish();
                startActivity(new Intent(AlarmActivity.this, LoginActivity.class));
            }
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (isNavgate) {
            initViewSetting();
        } else {
            isNavgate = Boolean.TRUE;
        }
    }

}
